import request from '@/router/axios';
export const loginByUsername = (account, password) => request({
  url: '/api/authService/login',
  method: 'post',
  meta: {
    isSerialize: true,
    isToken: false
  },
  data: {
    account,
    password,
    clientSource:"1"
  }
})
//获取全部字典列表
export const getAllDictionary = () => request({
    url: '/api/enumDict/allDict',
    method: 'post',
    meta: {
        isSerialize: true
    },
    data: {}
})

export const getImg = () => request({
  url: '/api/system/previewAvatar',
  method: 'post'
});
export const getUserInfo = () => request({
  url: '/api/getUserInfo',
  method: 'post'
});

export const refeshToken = (rToken) => request({
  url: '/api/authService/refresh',
  method: 'post',
  meta: {
    isSerialize: true,
    isToken: false
  },
  data: {
    rToken
  }
})

export const getMenu = () => request({
  url: '/api/menus',
  method: 'post'
});

export const getTopMenu = () => request({
  url: '/api/user/getTopMenu',
  method: 'post'
});

export const sendLogs = (list) => request({
  url: '/api/authService/logout',
  method: 'post',
  data: list
})
//修改退出登录之前
// url: '/api/authService/logout',
export const logout = () => {
  return request({
    url: '/api/authService/idmLogout',
    meta: {
      isSerialize: true,
      isToken: true
    },
    method: 'post',
    data: {
      token: 'token'
    }
  })
}


//以下是setting.vue页面需要调用的js

//通过原支付密码修改支付密码(专门给卖家用户类型为店铺用户用的)
export const changePwdByOriginal = (oldPassword,newPassword) => {
    return request({
        url: '/account/sellerUserAccount/changePwdByOld',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            oldPassword,
            newPassword
        }
    });
};


//通过原支付密码修改支付密码(专门给卖家用户类型为用户类型的用户用的)
export const changeUserPwdByOriginal = (oldPassword,newPassword) => {
    return request({
        url: '/account/buyerUserAccount/changePwdByOld',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            oldPassword,
            newPassword
        }
    });
};


//通过原密码修改密码
export const changeAccountPwdByOriginal = (oldPassword,newPassword) => {
    return request({
        url: '/api/sellerUser/changePwdByOld',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            oldPassword,
            newPassword
        }
    });
};



//(通过手机号修改支付密码时用到)校验手机号发送的验证码
export const testChangPwdByPhoneMsgCode = (mobile,msgCode,useType) => {
    return request({
        url: '/account/sellerUserAccount/checkVerifyCode',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            mobile,
            msgCode,
            useType
        }
    });
};


//通过手机号修改支付密码(修改的是卖家账户类型为店铺类型用户的支付密码)
export const changePwdByPhoneNumber = (newPassword,mobile,msgCode,useType) => {
    return request({
        url: '/account/sellerUserAccount/changePwdByPhone',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            newPassword,
            mobile,
            msgCode,
            useType
        }
    });
};

//通过手机号修改支付密码(修改的是卖家账户类型为个人用户类型用户的支付密码)
export const changeUserPwdByPhoneNumber = (newPassword,mobile,msgCode,useType) => {
    return request({
        url: '/account/buyerUserAccount/changePwdByPhone',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            newPassword,
            mobile,
            msgCode,
            useType
        }
    });
};




//(通过手机号修改账号密码)校验手机号
export const testChangAccountPwdByPhoneMsgCode = (mobile,msgCode,useType) => {
    return request({
        url: '/api/sellerUser/checkVerifyCode',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            mobile,
            msgCode,
            useType
        }
    });
};


//通过手机号修改账号密码
export const changeAccountPwdByPhoneNumber = (newPassword,mobile,msgCode,useType) => {
    return request({
        url: '/api/sellerUser/changePwdByPhone',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: {
            newPassword,
            mobile,
            msgCode,
            useType
        }
    });
};


//修改绑定的手机号
export const changePhone = (data) => {
    return request({
        url: '/api/sellerUser/changeRelationPhoneByPhone',
        method: "post",
        meta: {
            isSerialize: true,
        },
        data: data
    });
};



//获取用户信息
export const getAllUserInfo = () => request({
    url: '/api/getAllUserInfo',
    method: 'post'
});

//调用发送验证码的接口
export const getMsgCode = (data) => request({
    url: '/msg/verifyCode/getMsgCode',
    method: 'post',
    meta: {
        isSerialize: true,
    },
    data: data
})

export const getImageVerification = (phone) => request({
    url: '/api/authService/getImageVerification',
    responseType: "arraybuffer",
    method: 'get',
    params: {
        "phone": phone
    }
})

//调用发送验证码的接口
export const changePwdByOld = (oldPassword,newPassword) => request({
    url: '/api/mgr/changePwd',
    method: 'post',
    meta: {},
    params: {
        oldPassword:oldPassword,
        newPassword:newPassword
    }
})

export const saveOtherInfo = (data) => request({
  url: '/api/buyerUser/edit',
  method: 'post',
  meta: {
      isSerialize: true,
  },
  data: data
})

//接收地址，跳转idm
export const getIdmAuthoCodeUrl = () => request({
    url: '/system/authService/getIdmAuthoCodeUrl',
    method: 'post'
})
//接收code
export const getIdmAccessToken = (code) => request({
    url: '/system/authService/getIdmAccessToken',
    method: 'post',
    params:{
        "code":code
    }
})

//接收地址，跳转ibm
export const idmAutho2Login = (code) => request({
    url: '/api/authService/idmAutho2Login',
    method: 'get',
    params:{
        "code":code
    }
})


